package com.acwing.partition20;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/13 19:56
 */
public class AC1960闪烁 {

    private static final int N = 1 << 16;
    private static int n = 0;
    private static long m = 0;
    private static int[] visited = new int[N];

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        n = Integer.parseInt(s[0]);
        m = Long.parseLong(s[1]);
        int start = 0;
        //初始状态进行状态压缩，状态最多只有2^16个，需要变换1^15次，说明必定会存在环
        for (int i = 0; i < n; i++) {
            int curr = Integer.parseInt(reader.readLine());
            start |= curr << i;
        }
        int answer = resolve(start);
        for (int i = 0; i < n; i++) writer.write((answer >> i & 1) + "\n");
        writer.flush();
    }

    private static int resolve(int status) {
        for (int i = 0; i < 1 << 16; i++) visited[i] = -1;
        visited[status] = 0;
        for (int i = 1; ; i++) {
            status = update(status);
            //直接就走到了目的状态
            if (i == m) return status;
            //如果这个状态没有被访问过就进行访问，否则说明找到了环
            if (visited[status] == -1) visited[status] = i;
            else {
                //得到环的长度，并求余找最终结果
                int length = i - visited[status];
                long r = (m - i) % length;
                while (r-- > 0) status = update(status);
                return status;
            }
        }
    }

    private static int update(int statue) {
        int next = 0;
        for (int i = 0; i < n; i++) {
            int j = i == 0 ? n - 1 : i - 1;
            int x = statue >> i & 1, y = statue >> j & 1;
            next |= (x ^ y) << i;
        }
        return next;
    }
}
